//主程序 需要分页的页面引入该js
function holdnoGetMore(data){
  //alert(123);
  try{
    this.data = data;
    this.pageData = document.querySelectorAll('.'+data.len).length;
    this.sendUrl = data.url;
    console.log(document.querySelector(this.data.button));
    document.querySelector(this.data.button).setAttribute('onclick',this.data.name+'.getPage()');
  } catch(e) {
    console.log('实例化对象信息错误');
  }
}
holdnoGetMore.prototype.callback = function(){
  this.data.getData(data);
}
holdnoGetMore.prototype.error = function(){
  this.data.error;
}
holdnoGetMore.prototype.empty = function(){
  this.data.empty();
}
holdnoGetMore.prototype.getPage = function(){
   $.ajax({
    type:'post',
    url:this.sendUrl,
    data:{'len':this.pageData,'num':this.data.num},
    dataType:'json',
    success:function(data){
      if(data == 'empty'){
        this.empty();
      }else if(data.length < this.data.num){
        this.empty();
      }else{
        this.callback(data);
      }
    },
    error:function(data){
      this.error(data);
    },
    complete:function(){

    }
   });
}



//配置，放入需要分页的html中
p = new holdnoGetMore({
      name:'p',
      len:'holdnoData',
      url:'url',
      num:'10',
      button:'.holdnoAloneBotton',
      getData:function(data){
        var a = document.querySelector('.all');
            a.appendChild(data);
      },
      empty:function(data){
        var a = document.querySelector('.holdnoAloneBotton');
            a.parentNode.removeChild(a);
      }
});




function holdnoGame(data){
  //data
  //data.user 用户id
  //
  //
  try{
    this.data = data;
    
  } catch(e) {
    console.log('实例化对象信息错误');
  }
}

holdnoGame.prototype.percent = function(){
    var percent = Math.ceil(Math.random()*100);
    	if(percent <= 20){
			percent = Math.ceil(Math.random()*100);
			if(percent <= 30){
				//刷新怪物
			}else if(percent > 30 && percent <= 45){
				//掉落游戏装备
			}else if(percent > 45 && percent <= 50){
				//掉落代金券或商品
			}else if(percent > 50 && percent <= 80){
				//掉落藏宝图
			}else if(percent > 80){
				//掉落游戏币
			}
		}
}